<template>
    <div>
        <el-popover
                placement="down"
                width="400"
                trigger="click" v-model="carForm" ref="update_car_modal" style="position: relative;">
            <el-form :model="carList" label-width="100px" class="update-form">
                <el-form-item label="车辆牌照号">
                    <el-input v-model="carList.vehiclenumber"></el-input>
                </el-form-item>
                <el-form-item label="车辆颜色代码">
                    <el-input v-model="carList.vehicleplatecolorcode"></el-input>
                </el-form-item>
                <el-form-item label="车辆类型代码">
                    <el-input v-model="carList.vehicletype"></el-input>
                </el-form-item>
                <el-form-item label="所有人">
                    <el-input v-model="carList.owner"></el-input>
                </el-form-item>
                <el-form-item label="使用性质">
                    <el-input v-model="carList.usecharacter"></el-input>
                </el-form-item>
                <el-form-item label="车辆识别代号">
                    <el-input v-model="carList.vin"></el-input>
                </el-form-item>
                <el-form-item label="发证机关">
                    <el-input v-model="carList.issuingorganizations"></el-input>
                </el-form-item>
                <el-form-item label="注册日期">
                    <el-input v-model="carList.registerdate"></el-input>
                </el-form-item>
                <el-form-item label="发证日期">
                    <el-input v-model="carList.issuedate"></el-input>
                </el-form-item>
                <el-form-item label="车辆能源类型">
                    <el-input v-model="carList.vehicleenergytype"></el-input>
                </el-form-item>
                <el-form-item label="核定载质量">
                    <el-input v-model="carList.vehicletonnage"></el-input>
                </el-form-item>
                <el-form-item label="车辆总质量">
                    <el-input v-model="carList.grossmass"></el-input>
                </el-form-item>
                <el-form-item label="道路运输证号">
                    <el-input v-model="carList.roadtransportcertificatenumber"></el-input>
                </el-form-item>
                <el-form-item label="道路运输证字">
                    <el-input v-model="carList.roadtransportcertificateword"></el-input>
                </el-form-item>
                <el-form-item label="挂车牌照号">
                    <el-input v-model="carList.trailervehicleplatenumber"></el-input>
                </el-form-item>
                <el-form-item label="挂车荷载">
                    <el-input v-model="carList.trailervehicletonnage"></el-input>
                </el-form-item>
                <el-form-item label="挂车总质量">
                    <el-input v-model="carList.trailervehiclegrossmass"></el-input>
                </el-form-item>
                <el-form-item label="remark">
                    <el-input v-model="carList.remark"></el-input>
                </el-form-item>
                <el-form-item label="appkey">
                    <el-input v-model="carList.appkey"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="onSubmit('carForm')">立即创建</el-button>
                    <el-button @click="hideForm('carForm')">取消</el-button>
                </el-form-item>
            </el-form>
            <el-button slot="reference">上传车辆信息</el-button>
        </el-popover>
    </div>
</template>

<script>
    export default {
        name: "car",
        data(){
            return {
                case: false,
                carForm: false,
                carList: {
                    vehiclenumber: '辽H78747',  //车辆牌照号
                    vehicleplatecolorcode: '2',  //车牌颜色代码
                    vehicletype: 'Q11',    //车辆类型代码 Q11-重型半挂牵引车
                    owner: '营口瑞盈物流有限公司',  //所有人
                    usecharacter: '货运',   //使用性质
                    vin: 'LFWSRXPJ9A1E05900',    //车辆识别代号
                    issuingorganizations: '辽宁省营口市公安局交通警察支队',   //发证机关
                    registerdate: '20100309',   //注册日期
                    issuedate: '20191112',  //发证日期
                    vehicleenergytype: 'B',  //车辆能源类型
                    vehicletonnage: '40.00', //核定载质量
                    grossmass: '48.70',  //吨位 车辆总质量
                    roadtransportcertificatenumber: '10136627', //道路运输证号
                    roadtransportcertificateword: '营',   //道路运输证字
                    trailervehicleplatenumber: '辽HD127挂',  //挂车牌照号
                    trailervehicletonnage: '24.00',  //挂车荷载
                    trailervehiclegrossmass: '37.75',    //挂车总质量
                    remark: '', //
                    appkey: '13762'  //
                }
            }
        },
        methods: {
            defaultCar() {
                return `
        <reqInfo>
        <root>
        <header>
	    <messagereferencenumber>###UUID###</messagereferencenumber>
	    <documentname>车辆基本信息</documentname>
	    <documentversionnumber>2.0</documentversionnumber>
	    <sendercode>210000</sendercode>
	    <enterprisesendercode>2113762</enterprisesendercode>
	    <messagesendingdatetime>###TIME###</messagesendingdatetime>
	    <ipctype>WLHY_CL1001</ipctype>
	    <token>427690567060f4d98f24c10099fcaa98</token>
	    <messagefunctioncode>9</messagefunctioncode>
	    <recipientcode>wcjc0002</recipientcode>
        </header>
`
            },
            onSubmit(formName){
                this.hideForm(formName)
                let header = this.defaultCar()
                let str = `
               ${header}<body>
               <vehiclenumber>${this.carList.vehiclenumber}</vehiclenumber>
               <vehicleplatecolorcode>${this.carList.vehicleplatecolorcode}</vehicleplatecolorcode>
               <vehicletype>${this.carList.vehicletype}</vehicletype>
               <owner>${this.carList.owner}</owner>
               <usecharacter>${this.carList.usecharacter}</usecharacter>
               <vin>${this.carList.vin}</vin>
               <issuingorganizations>${this.carList.issuingorganizations}</issuingorganizations>
               <registerdate>${this.carList.registerdate}</registerdate>
               <issuedate>${this.carList.issuedate}</issuedate>
               <vehicleenergytype>${this.carList.vehicleenergytype}</vehicleenergytype>
               <vehicletonnage>${this.carList.vehicletonnage}</vehicletonnage>
               <grossmass>${this.carList.grossmass}</grossmass>
               <roadtransportcertificatenumber>${this.carList.roadtransportcertificatenumber}</roadtransportcertificatenumber>
               <roadtransportcertificateword>${this.carList.roadtransportcertificateword}</roadtransportcertificateword>
               <trailervehicleplatenumber>${this.carList.trailervehicleplatenumber}</trailervehicleplatenumber>
               <trailervehicletonnage>${this.carList.trailervehicletonnage}</trailervehicletonnage>
               <trailervehiclegrossmass>${this.carList.trailervehiclegrossmass}</trailervehiclegrossmass>
               <remark>${this.carList.remark}</remark>
               <appkey>${this.carList.appkey}</appkey>
               </body>
               </root>
               </reqInfo>
                `
                console.log(str);
                this.cusMark()
                this.api.dataPost.carInfo(str).then((res) => {
                    console.log(res);
                    this.handleRes(res)
                }).catch((res) => {
                    console.log(res);
                })
            },
        },
        mounted() {
        }
    }
</script>

<style scoped>

</style>